// 模拟 filterAsyncRoute 的过滤逻辑

// 模拟 autoasync 构建的路由结构（简化版）
const asyncroutes = [
  {
    path: '/message',
    name: 'message',  // autoasync 创建的包装路由
    component: 'PageLayout',
    children: [
      {
        path: 'message',
        name: 'Message',  // 实际的 Message 路由
        component: 'Page.vue',
        meta: { title: '消息管理' }
      }
    ]
  }
];

// 用户权限中的 routes
const userRoutes = [
  "Acl",
  "User",
  "Role",
  "Permission",
  "Screen",
  "Dashboard",
  "Product",
  "Trademark",
  "Message"
];

console.log('原始路由结构:');
console.log(JSON.stringify(asyncroutes, null, 2));

console.log('\n用户权限 routes:', userRoutes);

const filterAsyncRoute = (asyncroutes, routes) => {
  return asyncroutes.filter((item) => {
    if (item.name && routes.includes(item.name)) {
      if (item.children && item.children.length > 0) {
        item.children = filterAsyncRoute(item.children, routes)
      }
      return true
    }
  })
};

const filtered = filterAsyncRoute(asyncroutes, userRoutes);

console.log('\n过滤后的路由:');
console.log(JSON.stringify(filtered, null, 2));

console.log('\n问题分析:');
console.log('- 包装路由名称: "message" (小写)');
console.log('- 实际路由名称: "Message" (首字母大写)');
console.log('- 用户权限中有: "Message"');
console.log('- 所以包装路由被过滤掉了，虽然子路由是匹配的');
